<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 01:16:57
 * @LastEditTime: 2023-08-28 13:37:29
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Models;

use App\Traits\MaterialTrait;
use App\Traits\SoftDeletesTrait;
use Illuminate\Support\Facades\App;

class MpcSummaryDetail extends BaseModel
    {
    use SoftDeletesTrait;
    use MaterialTrait;
    public $timestamps = true;
    public $table = "sys_mpc_summary_detail";
    protected $guarded = [];
    //库位 
    protected $casts = [];

    public function getSourceAttribute()
        {
        return App::make($this->source_model)->where($this->source_key, "=", $this->source_value)->first();
        }
    public function details()
        {
        return $this->hasMany(MpcBatchDetail::class, "summary_detail_id");
        }
    public function maindetails()
        {
        return $this->hasMany(MpcSummaryDetail::class, "main_id");
        }
    }